/*
 * Copyright (c) 2015 DHC Corporation.
 */
package cn.com.dhc.danlu.activity.goods;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

import java.util.List;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.activity.BaseActivity;
import cn.com.dhc.danlu.widget.GoodInfoListView;
import cn.com.dhc.danlu.widget.adapter.GoodInfoInstructionListViewAdapter;

/**
 * 商品描述画面
 *
 * @author LiYongHe
 * @version 1.00 2015/03/06 新建
 */
public class GoodInfoInstructionActivity extends BaseActivity implements OnClickListener {

    /**
     * 详细商品数据类名常量
     */
    private static final String INTENT_DATA = "data";
    /**
     * 商品描述
     */
    private GoodInfoListView lstImage;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 实例化画面控件
        setContentView(R.layout.layout_good_info_instruction);

        LinearLayout llytBack = (LinearLayout) findViewById(R.id.llytBack);
        llytBack.setOnClickListener(this);

        lstImage = (GoodInfoListView) findViewById(R.id.lstImage);
        lstImage.setSelector(new ColorDrawable(Color.TRANSPARENT));

        // 画面初始化
        init();
    }

    @Override
    protected String getActivityTitle() {
        return null;
    }

    /**
     * 画面初始化
     */
    private void init() {
        // 初始化传值对象
        initListView(getIntent().getExtras().getStringArrayList(INTENT_DATA));
    }


    private void initListView(List<String> url) {
        Log.e("@@@@ L67", "GoodInfoInstructionActivity:initListView() -> url = " + url);
        // 存放图片的List
        if (null != url && !url.isEmpty()) {
            lstImage.setDivider(null);
            // 显示图片的ListView的适配器
            GoodInfoInstructionListViewAdapter adapter = new GoodInfoInstructionListViewAdapter(this);
            // 为ListView设置适配器
            lstImage.setAdapter(adapter);
            adapter.refreshData(url);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.llytBack:
                finish();
                break;

            default:
                break;
        }
    }
}